#include "myGame.h"

void MyGame::Startup()
{
	/* This method is called once, when the game is first started. Here you can create
	   your games window. */
	this->CreateGraphicsWindow("texture 3D", 800, 600, 32, false);

	this->pLogoTexture = this->pEngine->GetGraphics()->LoadTexture("../media/logo.png");
}

void MyGame::Shutdown()
{
	/* This method is called once, when the game is being shutdown. */
	this->pEngine->GetGraphics()->UnloadTexture(this->pLogoTexture);

	this->DestroyGraphicsWindow();
}

void MyGame::Update(float fDelta)
{
	/* This method is called every frame and can be used fo global processing,
	   such as a quit game button. */
	this->UpdateCurrentScreen(fDelta);

	if (this->pEngine->GetInput()->IsKeyHit(DelGE_Key_Escape))
		this->bIsRunning = false;
}

void MyGame::Render()
{
	/* This method is called every frame. Here you can do the prerendering for
	   the current screen, and then render that screen. For the examples I render
	   a texture that displays the logo over the top of any screen rendering. */
	this->pEngine->GetGraphics()->ClearScreen();

	this->pEngine->GetGraphics()->SetModelViewMatrix(Matrix::Identity());

	this->RenderCurrentScreen();

	this->pEngine->GetGraphics()->SetModelViewMatrix(Matrix::Identity());

	this->pEngine->GetGraphics()->SetGlobalColor(DELGE_GRAPHICSCOLOR_WHITE);
	this->pEngine->GetGraphics()->SetBlendMode(DelGEGraphicsBlendMode_Alpha);

	this->pEngine->GetGraphics()->DrawTexture(this->pLogoTexture, this->GetGraphicsWidth() - (this->pLogoTexture->GetWidth() + 10.0f),
																  this->GetGraphicsHeight() - (this->pLogoTexture->GetHeight() + 10.0f));

	this->pEngine->GetGraphics()->Flip();
}